package com.example.demo.controller;


import com.example.demo.services.GetDataServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.io.IOException;

/**
 * @author liyixuan
 * @version 14
 * @date 2021年5月13日15:48:29
 */
@Controller
public class GetDataController {
    @Autowired
    private GetDataServices services;

    @GetMapping("show")
    public String getData(Model model) throws IOException {
        model.addAttribute("data", services.getData());
        return "index";
    }

    @GetMapping("search")
    public String getData2(String address, Model model) throws IOException {
        model.addAttribute("data", services.searchDataModel(address));
        System.out.println(services.searchDataModel(address));
        return "index";
    }
}
